package com.wl.index.web.feign;

import com.wl.bean.Result;
import com.wl.dm.entity.Product;
import com.wl.dm.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
//一个服务只能定义在一个接口
@FeignClient("cloud-other")
public interface OtherAction {
    @RequestMapping("product/hots")
    List<Product> queryHots();

    @RequestMapping("/feignadd")
        //服务端   属于在远程调用中被调用的这一端
    int add(@RequestParam("a") int a,
            @RequestParam("b") int b);

    //对象的属性映射为请求参数名，这就是自动装箱
    @RequestMapping("/feignres")
    Result res(@SpringQueryMap Result result);

    //用户信息是通过请求体body传递过来的
    @RequestMapping("/feignuser")
    User user(@RequestBody User user,
              @RequestParam("myname") String myname);

    //Restful（一般写在地址里面，地址参数） 请求方式
    @RequestMapping("/feign/hello/{nm}")
    String hello(@PathVariable("nm") String name);
}
